#!/usr/bin/env python
# -*- coding: utf-8 -*-

from core.utils.singleton import singleton
from xml.etree.ElementTree import ElementTree
import shutil
import os
import os.path as path


@singleton
class DataMangager:

    def __init__(self):
        """allo"""
        
        self.home=os.getenv('HOME') or os.getenv('LOCALAPPDATA')
        self.home+='/.druid'
        self._sections={}
        self._sections
        self._category={}
        if not os.path.exists(self.home+'/userdata.xml'):
            self._createData()
        self._readData()
    
    #def getData(self,section,name):
    #    return self._sections[dataInfos.section][dataInfos.name]
    
    def getData(self,section,name,defaulValue=None,defaulValues=None,defaulCategory="Generic"):
        '''allo'''
        #section=section[0].capitalize()+section[1:]
        if self._sections.has_key(section) and self._sections[section].has_key(name):
             data=self._sections[dataInfos.section][dataInfos.name]
        else:
            data=DataInfos(section,name,defaulValue,defaulValues,defaulCategory)
            self.addDataInfos(data)
        return data
    
    def getSections(self):
        allo=""
        ret=self._sections.keys()
        ret.remove("Druid")
        ret.insert(0,"Druid")
        return ret